﻿Imports System.Data.SqlClient
Public Class FormTypeEditor

    Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click
        Me.DialogResult = Windows.Forms.DialogResult.Cancel
    End Sub

    Private Sub btnOk_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOk.Click
        If txtTypeName.Text.Trim() = "" Then
            MsgBox("Please insert Type Name!!!")
            txtTypeName.Focus()
            Exit Sub
        End If
        Cmd.Parameters("@TypeName") = txtTypeName.Text
        If Me.txtTypId.Text = "" Then
            Cmd.ExecuteNonQuery("INSERT INTO Type VALUES(@TypeName,1);")
        Else
            Cmd.Parameters("@TypeId") = txtTypId.Text
            Cmd.ExecuteNonQuery("UPDATE Type SET TypeName=@TypeName WHERE TypeId=@TypeId")
        End If
        Me.DialogResult = Windows.Forms.DialogResult.OK
    End Sub

    Private Sub FormTypeEditor_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub
End Class